import os
import pdf2docx

# 定义PDF文件和目标文件夹的路径
pdf_folder = 'F:\pdf'
docx_folder = 'E:\watchic_app\word'

# 遍历PDF文件夹中的所有PDF文件，并将它们转换为Word文档
for pdf_file in os.listdir(pdf_folder):
    if pdf_file.endswith('.pdf'):
        pdf_path = os.path.join(pdf_folder, pdf_file)
        docx_file = pdf_file[:-4] + '.docx'
        docx_path = os.path.join(docx_folder, docx_file)
        pdf2docx.parse(pdf_path, docx_path)